import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)


let state={
    username:"",
    roleName:"",
    U_tk:"" //token user
}
const mutations = {
    setuserInfo(state,data){
        state.username=data.u;
        state.roleName=data.r;
        state.U_tk=data.t;
        sessionStorage.setItem("username", data.u); 
        sessionStorage.setItem("roleName", data.r); 
        sessionStorage.setItem("U_tk", data.t); 
    },
    clearUserData(){
        state.roleName=null;
        state.username=null;
        state.U_tk=null;
        sessionStorage.removeItem("username")
        sessionStorage.removeItem("roleName")
        sessionStorage.removeItem("U_tk")
    }
}
export default new Vuex.Store({
    state,mutations
   
})